<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <script type="text/javascript" src="js/jquery.js"></script>
  <script type="text/javascript" >
    $(function () {
      //发送Ajax请求进行班级的查询
      $.post("www/RoomServlet?method=findAll",function (f) {

        $.each(f,function (i,e) {

          $("#sel").append('<option value="'+e.rid+'">'+e.rname+'</option>')
        })
      },"json")

      $("#sub").click(function () {

        $.post("www/ScoreServlet?method=save",$("#form").serialize(),function (f) {

          if(f>0){
              alert("录入成功！")
            window.location.href="score.html"
            }else {
              alert("录入失败！")
            }
        },"json")
      })
    })
  </script>
</head>
<body>

<form id="form">
  <p>
    姓名:<input type="text" name="sname">
  </p>

  <p>
    理论成绩:<input type="text" name="first">
  </p>

  <p>
    机试成绩:<input type="text" name="second">
  </p>

  <div class="form-group">
    <div class="label">
      <label>所在班级：</label>
    </div>
    <div class="field">

      <select class="input" style="width:30%" id="sel" name="srid">
        <option>--请选择--</option>
      </select>
    </div>
  </div>

  <p>
    <input type="button" value="录入" id="sub">
  </p>

</form>

</body>
</html>